﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Quanlytruongtruongtieuhoc
{
    public partial class frmThongtingiaovien : Form
    {
        public frmThongtingiaovien()
        {
            InitializeComponent();
        }

        private void frmThongtingiaovien_Load(object sender, EventArgs e)
        {
            try
            {
                clsKetnoi.taoKetnoi();
                this.Text = this.Text + frmDangnhap.ho + " " + frmDangnhap.ten;
                lbTengv.Text = frmDangnhap.ho + " " + frmDangnhap.ten;
                txtHoten.Text = frmDangnhap.ho + " " + frmDangnhap.ten;
                txtMagv.Text = frmDangnhap.magv;
                SqlDataAdapter ap = new SqlDataAdapter("select a.ten_lv,b.ten_td,c.scmnd,convert(char(10),c.nam_sinh,103) as namsinh,c.dia_chi_ht from linhvuc_giang_day a,trinh_do b,giao_vien c where c.ma_td=b.ma_td and c.ma_lv=a.ma_lv and c.ma_gv='" + frmDangnhap.magv + "'", clsKetnoi.con);
                DataTable gv = new DataTable();
                ap.Fill(gv);
                for (int i = 0; i < gv.Rows.Count; i++)
                {
                    DataRow row = gv.Rows[i];
                    txtLinhvuc.Text = row[0].ToString();
                    txtTrinhdo.Text = row[1].ToString();
                    txtCMND.Text = row[2].ToString();
                    txtNamsinh.Text = row[3].ToString();
                    txtDiachi.Text = row[4].ToString();
                }
                SqlCommand com2 = new SqlCommand("select gioi_tinh from giao_vien where ma_gv='" + frmDangnhap.magv + "'", clsKetnoi.con);
                string gt =com2.ExecuteScalar().ToString();
                txtGioitinh.Text = gt;
               
                SqlCommand com = new SqlCommand("select hinh from giao_vien where ma_gv='" + frmDangnhap.magv + "'", clsKetnoi.con);
                try
                {
                    byte[] a = (byte[])com.ExecuteScalar();
                    pcbHinhanh.Image = clsHinhanh.ByteArrayToImage(a);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Không có hình ảnh hiển thị ", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {

        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
    }
}
